package com.scproject.scbef.controller.study.studyresource;

import com.scproject.annotations.LoginVerifyToken;
import com.scproject.annotations.PassToken;
import com.scproject.dto.ResponseDto;
import com.scproject.scbef.service.study.studyresource.StudyResourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartHttpServletRequest;

/**
 * @author LNL
 * @date 2021/5/24 15:27
 */
@RestController
@RequestMapping("/study")
@Api(tags = "学习资料")
public class StudyResourceController {

    @Autowired
    private StudyResourceService studyResourceService;


    @GetMapping("/resources")
    @ApiOperation("获取所有学习资料")
    @PassToken
    public ResponseDto getAllStudyResources() {
        ResponseDto responseDto = studyResourceService.getAllStudyResources();
        return responseDto;
    }

    @PostMapping("/insert")
    @ApiOperation("上传学习资料")
    @LoginVerifyToken
    public ResponseDto insertStudyResource(MultipartHttpServletRequest request) {
        ResponseDto responseDto = studyResourceService.insertStudyResource(request);
        return responseDto;
    }

    @PostMapping("/delete/{id}")
    @ApiOperation("删除学习资料")
    @LoginVerifyToken
    public ResponseDto deleteStudyResource(@PathVariable("id") String id){
        ResponseDto responseDto = studyResourceService.deleteStudyResource(id);
        return responseDto;
    }

    @PostMapping("/update")
    @ApiOperation("修改学习资料")
    @LoginVerifyToken
    public ResponseDto updateStudyResource(MultipartHttpServletRequest request){
        ResponseDto responseDto = studyResourceService.updateStudyResource(request);
        return responseDto;
    }
}
